<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>系统管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/static/admin/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/admin/css/public.css" media="all">
</head>
<body>
<div class="layui-tab layui-tab-card">
    <ul class="layui-tab-title">
        <li class="layui-this">网站配置</li>
        <li>微信配置</li>
        <li>邮件配置</li>
    </ul>
    <div class="layui-tab-content">

        <div class="layui-tab-item layui-show">
            <form class="layui-form" action="">
                {volist name="lists" id="ls"}
                    {if $ls.system_iden == 'web'}
                        {if $ls.system_group == 1}
                        <div class="layui-form-item">
                            <label class="layui-form-label">{$ls.system_name}</label>
                            <div class="layui-input-block">
                                <input type="text" name="{$ls.input_name}"  autocomplete="off" placeholder="请输入{$ls.system_name}" class="layui-input" value="{$ls.system_content}">
                            </div>
                        </div>
                        {elseif $ls.system_group ==2 /}
                            <div class="layui-form-item">
                                <label class="layui-form-label">{$ls.system_name}</label>
                                <div class="layui-upload-drag" id="upload">
                                    <i class="layui-icon"></i>
                                    <p>点击上传，或将文件拖拽到此处</p>
                                    {if !empty($ls.system_content)}
                                    <div class="layui-hide" id="uploadDemoView">
                                        <hr>
                                        <img src="{$ls.system_content}" alt="上传成功后渲染" style="max-width: 196px">
                                        <input type="hidden" name="{$ls.input_name}" value="{$ls.system_content}">
                                    </div>
                                    {/if}
                                </div>
                            </div>
                        {elseif $ls.system_group == 6/}
                            <div class="layui-form-item">
                                <label class="layui-form-label">{$ls.system_name}</label>
                                <div class="layui-input-block">
                                    <textarea name="{$ls.input_name}" placeholder="请输入关键词" class="layui-textarea">{$ls.system_content}</textarea>
                                </div>
                            </div>
                        {/if}
                    {/if}
                {/volist}
                <input type="hidden" name="system_iden" value="web">
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button type="button" class="layui-btn" lay-submit="" lay-filter="sub_web">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
        <div class="layui-tab-item">
            <form class="layui-form" action="">
                {volist name="lists" id="ls"}
                    {if $ls.system_iden == 'wechat'}
                        {if $ls.system_group == 1}
                            <div class="layui-form-item">
                                <label class="layui-form-label">{$ls.system_name}</label>
                                <div class="layui-input-block">
                                    <input type="text" name="{$ls.input_name}"  autocomplete="off" placeholder="请输入{$ls.system_name}" class="layui-input" value="{$ls.system_content}">
                                </div>
                            </div>
                        {/if}
                    {/if}
                {/volist}
                <input type="hidden" name="system_iden" value="wechat">
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button type="button" class="layui-btn" lay-submit="" lay-filter="sub_wechat">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
        <div class="layui-tab-item">3</div>
        <div class="layui-tab-item">4</div>
        <div class="layui-tab-item">5</div>
        <div class="layui-tab-item">6</div>
    </div>
</div>

<script src="/static/admin/lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
<script src="/static/admin/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>

<script>
    layui.use(["form",'upload'],function(){
        var $ = layui.$
        , upload = layui.upload
        , form = layui.form;

        // 图片上传
        upload.render({
            elem: '#upload'
            ,url: '/back/upload/uploads' //改成您自己的上传接口
            ,done: function(res){
                layer.msg('上传成功');
                layui.$('#uploadDemoView').removeClass('layui-hide').find('img').attr('src', res.path);
                layui.$('#uploadDemoView').find('input').attr('value', res.path);
            }
        });



        // 网站配置
        form.on("submit(sub_web)",function(data){
            data = data.field;
            
            $.ajax({
                url : '/back/system/edit',
                type :'POST',
                data : data,
                beforeSend:function(){
                    layer.msg('修改中,请稍后',{icon:16,shade:0.8});
                },
                success:function(res){
                    if(res.code == 1){
                        layui.msg(res.msg,{icon:1},function(){
                            parent.location.reload();
                        });
                    }else{
                        layui.msg(res.msg,{icon:2},function(){
                            parent.location.reload();
                        });
                    }
                }
            });
        });

        // 微信配置
        form.on("submit(sub_wechat)",function(data){
            data = data.field;

            $.ajax({
                url : '/back/system/edit',
                type :'POST',
                data : data,
                beforeSend:function(){
                    layer.msg('修改中,请稍后',{icon:16,shade:0.8});
                },
                success:function(res){
                    if(res.code == 1){
                        layui.msg(res.msg,{icon:1},function(){
                            parent.location.reload();
                        });
                    }else{
                        layui.msg(res.msg,{icon:2},function(){
                            parent.location.reload();
                        });
                    }
                }
            });
        });
    });
</script>

</body>
</html>